<%include inc/header.ejs%>
<style>
    body{background-color: #e9e9e9;}
</style>
<!-- html主体代码 start -->

<div class="clear box login">
    <h1 class="wfont" style="text-align: center;font-size: 40px;margin-top: 80px;">
        OS管理信息平台
    </h1>
    <hr>
    <form class="layui-form layui-form-pane1" id="data-form" style="width: 60%;margin: 0 auto;">
        <div class="layui-form-item">
            <label class="layui-form-label wfont">用户名：</label>
            <div class="layui-input-block">
                <input type="text" name="userName" id="xuserName" required value="taller"
                       placeholder="请输入用户名" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label wfont">密码：</label>
            <div class="layui-input-block">
                <input type="password" name="password" id="xpassword" required value="111111"
                       placeholder="请输入密码" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label wfont">验证码：</label>
            <div class="layui-input-block">
                <input type="text" name="yzm" id="xyzm" lay-verify="" required maxlength="6"
                       placeholder="请输入验证码" autocomplete="off"style="width: 300px;display: block;float: left;" class="layui-input">
                <a href="javascript:" id="reloadCode" style="display: block;float: left; margin-left: 5px;">
                    <img height="38" id="imgCode" alt="验证码" src="/login/code"></a>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label"></label>
            <button id="btnLogin" class="layui-btn layui-btn-normal btn-center f-right" type="button"> 登  录 </button>
        </div>
    </form>
</div>

<!-- html主体代码 end -->
<%include inc/js.ejs%>
<!-- 私有脚本 start -->
<script>
    $(function () {
        $('#reloadCode').click(function () {
            $('#imgCode').attr('src','/login/code?t='+ Math.random());
        })
        $('#btnLogin').click(function () {
            var obj = getFrom('#data-form');
            log(obj)
            if(autoRequired('x',obj)){
                var param = {url:'/login',data:obj,type:'POST'};
                var request = $.ajaxs(param);
                request.done(function(d){
                    if(d.error == 0){
                        toPage("/desktop");
                    }else {
                        $('#imgCode').attr('src','/login/code?t='+ Math.random());
                        tips(d.message);
                    }
                }).fail(function () {
                    tips("网络异常");
                });
            }
        })
    })
</script>
<!-- 私有脚本 end -->
<%include inc/footer.ejs%>